<template>
  <div class="loan-success-container">
    <!-- 顶部导航栏 -->
    <div class="loan-success-header">
      <div class="back-button" @click="goBack">
        <el-icon><ArrowLeft /></el-icon>
      </div>
      <div class="header-title">申请结果</div>
      <div class="placeholder"></div>
    </div>

    <!-- 成功内容 -->
    <div class="loan-success-content">
      <!-- 成功图标和信息 -->
      <div class="success-section">
        <div class="success-icon">
          <el-icon size="80" color="#67C23A"><CircleCheck /></el-icon>
        </div>
        
        <div class="success-title">恭喜！您的申请额度</div>
        <div class="success-amount">{{ formatAmount(loanAmount) }}已通过！</div>
        
        <div class="success-tips">
          <el-icon><InfoFilled /></el-icon>
          <span>请保持您的申请状态，点击下方按钮查看详情并完成后续流程</span>
        </div>
      </div>

      <!-- 操作按钮 -->
      <div class="action-section">
        <el-button 
          type="primary" 
          size="large" 
          class="detail-button"
          @click="goToLoanList"
        >
          查看详细
        </el-button>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue';
import { useRouter, useRoute } from 'vue-router';
import { ArrowLeft, CircleCheck, InfoFilled } from '@element-plus/icons-vue';

const router = useRouter();
const route = useRoute();

// 贷款金额
const loanAmount = ref(50000);

// 格式化金额显示
const formatAmount = (amount) => {
  return amount.toLocaleString();
};

// 返回上一页
const goBack = () => {
  router.back();
};

// 跳转到我的借款页面
const goToLoanList = () => {
  router.push('/loan');
};

// 页面加载时获取申请金额
onMounted(() => {
  // 从路由参数或store中获取申请金额
  if (route.query.amount) {
    loanAmount.value = parseInt(route.query.amount);
  }
});
</script>

<style scoped>
.loan-success-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

.loan-success-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 50px;
  background-color: #3a4a7f;
  color: white;
  padding: 0 15px;
}

.back-button {
  font-size: 20px;
  cursor: pointer;
}

.header-title {
  font-size: 18px;
  font-weight: bold;
}

.placeholder {
  width: 20px;
}

.loan-success-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 40px 20px;
}

.success-section {
  text-align: center;
  margin-bottom: 60px;
}

.success-icon {
  margin-bottom: 30px;
  animation: bounce 2s infinite;
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-10px);
  }
  60% {
    transform: translateY(-5px);
  }
}

.success-title {
  font-size: 20px;
  color: #333;
  margin-bottom: 10px;
  font-weight: 500;
}

.success-amount {
  font-size: 28px;
  color: #67C23A;
  font-weight: bold;
  margin-bottom: 30px;
}

.success-tips {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(255, 255, 255, 0.9);
  padding: 15px 20px;
  border-radius: 8px;
  color: #666;
  font-size: 14px;
  line-height: 1.5;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  max-width: 300px;
}

.success-tips .el-icon {
  margin-right: 8px;
  color: #409EFF;
}

.action-section {
  width: 100%;
  max-width: 300px;
}

.detail-button {
  width: 100%;
  height: 50px;
  font-size: 18px;
  border-radius: 25px;
  background: linear-gradient(45deg, #FF6B35, #F7931E);
  border: none;
  box-shadow: 0 4px 15px rgba(255, 107, 53, 0.4);
  transition: all 0.3s ease;
}

.detail-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 107, 53, 0.6);
}

.detail-button:active {
  transform: translateY(0);
}
</style>